package com.example.course.controller.user;

import com.example.course.dto.user.UserLoginDto;
import com.example.course.service.UserService;
import com.example.course.utils.common.enums.Code;
import com.example.course.utils.common.result.Result;
import com.example.course.utils.config.BaseContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/user/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result login(@RequestBody UserLoginDto dto){
        return userService.login(dto);
    }

    @GetMapping("/user_login_out")
    public Result loginOut(){
        BaseContext.removeCurrentId();
        return Result.okResult(Code.SUCCESS);
    }

}
